<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <base href="<%=request.getContextPath()%>/">
  <meta charset="UTF-8">
  <title>新增支付</title>
  <link rel="stylesheet" href="statics/css/newsStyle.css">
  <style>
    .error-message {
      color: red;
      margin-bottom: 15px;
      padding: 10px;
      background-color: #ffeeee;
      border: 1px solid #ffcccc;
      border-radius: 4px;
    }
  </style>
</head>
<body>
<%@include file="../common/sidebar.jsp"%>
<div class="main-content">
  <%@include file="../common/top.jsp"%>
  <div class="content">
    <div class="card">
      <h2 class="section-title">新增支付</h2>

      <!-- 错误提示 -->
      <c:if test="${not empty error}">
        <div class="error-message">
            ${error}
        </div>
      </c:if>

      <form action="pay/add" method="post">
        <div class="form-group">
          <label>选择预约：</label>
          <select name="appointmentId" class="form-control" required>
            <option value="">-- 请选择预约 --</option>
            <c:forEach items="${unpaidAppointments}" var="appointment">
              <option value="${appointment.appointmentId}">
                  ${appointment.patientName} - ${appointment.visit.department.deptName} - ${appointment.visit.visitDate}
              </option>
            </c:forEach>
          </select>
        </div>
        <div class="form-group">
          <label>支付金额：</label>
          <input type="number" step="0.01" name="amount" class="form-control" min="0.01" required>
        </div>
        <div class="form-group">
          <label>支付方式：</label>
          <select name="payMethod" class="form-control" required>
            <option value="微信支付">微信支付</option>
            <option value="支付宝">支付宝</option>
            <option value="银行卡">银行卡</option>
            <option value="现金">现金</option>
          </select>
        </div>
        <div class="form-group">
          <label>支付状态：</label>
          <select name="status" class="form-control">
            <option value="0">待支付</option>
            <option value="1">已支付</option>
          </select>
        </div>
        <div class="form-actions">
          <button type="submit" class="btn btn-primary">保存</button>
          <a href="pay/find" class="btn btn-default">取消</a>
        </div>
      </form>
    </div>
  </div>
</div>
</body>
</html>